module.exports = app => {
    const { INTEGER, STRING } = app.Sequelize;

    const Model = app.model.define(
        'member_complaint',
        {
            type: {
                type: INTEGER,
                allowNull: false,
                defaultValue: 1
            },
            state: {
                type: INTEGER,
                allowNull: false,
                defaultValue: 1
            },
            user_id: {
                type: INTEGER,
                allowNull: false
            },
            target_user_id: {
                type: INTEGER,
                allowNull: false
            },
            content: {
                type: STRING,
                allowNull: false
            },
            image: {
                type: STRING(128),
                allowNull: true
            },
            replay: {
                type: STRING,
                allowNull: true
            },
        },
        {
            tableName: 'tbl_member_complaint',
            timestamps: true,
            underscored: true,
            charset: 'utf8',
            collate: 'utf8_general_ci'
        });

    Model.createTable = async () => {
        try {
            return await Model.sync({force: true});
        } catch (error) {
            return error.message;
        }
    };

    return Model;
};